From: Florian Müllner Date: Thu, 23 Jun 2022 16:17:57 +0000 (+0200) Subject: remoteSearch: Stop using callback to return loaded providers X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~461^2^2~201 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=1cce999c30ea1f471b135549f269dd073ab49612;p=gnome-shell.git remoteSearch: Stop using callback to return loaded providers Provider loading has been synchronous since 2013, so we can just as well return the results directly instead of passing them to a callback. Even if we returned to asynchronous loading in the future, we wouldn't want to use a callback, but make the function itself async. Part-of: --- diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js index 8ebb55052..d9eef287f 100644 --- a/js/ui/remoteSearch.js +++ b/js/ui/remoteSearch.js @@ -60,7 +60,13 @@ const SearchProvider2Iface = ` var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface); var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface); -function loadRemoteSearchProviders(searchSettings, callback) { +/** + * loadRemoteSearchProviders: + * + * @param {Gio.Settings} searchSettings - search settings + * @returns {RemoteSearchProvider[]} - the list of remote providers + */ +function loadRemoteSearchProviders(searchSettings) { let objectPaths = {}; let loadedProviders = []; @@ -130,10 +136,8 @@ function loadRemoteSearchProviders(searchSettings, callback) { } } - if (searchSettings.get_boolean('disable-external')) { - callback([]); - return; - } + if (searchSettings.get_boolean('disable-external')) + return []; FileUtils.collectFromDatadirs('search-providers', false, loadRemoteSearchProvider); @@ -184,7 +188,7 @@ function loadRemoteSearchProviders(searchSettings, callback) { return idxA - idxB; }); - callback(loadedProviders); + return loadedProviders; } var RemoteSearchProvider = class { diff --git a/js/ui/search.js b/js/ui/search.js index 3bfb83f9f..5375e7fc6 100644 --- a/js/ui/search.js +++ b/js/ui/search.js @@ -615,9 +615,8 @@ var SearchResultsView = GObject.registerClass({ this._unregisterProvider(provider); }); - RemoteSearch.loadRemoteSearchProviders(this._searchSettings, providers => { - providers.forEach(this._registerProvider.bind(this)); - }); + const providers = RemoteSearch.loadRemoteSearchProviders(this._searchSettings); + providers.forEach(this._registerProvider.bind(this)); } _registerProvider(provider) {